
package thread;

/**
 * sleep方法要求必须处理中断异常
 * 当一个线程调用sleep方法处于睡眠阻塞的过程中，此刻该线程的interrupt()方法
 * 被调用时会立即中断该睡眠阻塞，并抛出中断异常。
 */
        public class SleepDemo2 {
            public static void main(String[] args) {
                Thread lin=new Thread(){
                    public void run(){
                        System.out.println("林，刚美容大大大大大大");

                        try{
                            Thread.sleep(50000);
                        }catch(InterruptedException e){
                            System.out.println("LINDADADA.ENENEN");

                        }
                        System.out.println("xingl");
                    }

                };
                Thread huang=new Thread(){
                    public void run(){
                        System.out.println("ssssss!");
                        for (int i = 0; i < 5; i++) {
                            System.out.println("huang 80");
                            try {
                                Thread.sleep(1000);
                            } catch (InterruptedException e) {
                            }
                        }
                        System.out.println("sss");
                        System.out.println("SSDSDS");

                        lin.interrupt();//中断lin线程的睡眠阻塞
                    }
                };
                lin.start();
                huang.start();






            }
}
